<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 定义数组
        let arr = [1, 2, 3, 4, 5, 6, 7, 8, 9]
        // 最大值
        function max() {
            let max1 = arr[0]
            for (let i = 0; i < arr.length; i++) {
                if (arr[i] > max1) {
                    max1 = arr[i]
                }
            }
            document.write(max1 + "<br>")
        }
        // 最小值
        function min() {
            let min1 = arr[0]
            for (let i = 0; i < arr.length; i++) {
                if (arr[i] < min) {
                    min1 = arr[i]
                }
            }
            document.write(min1 + "<br>")
        }
        // 查找数字
        let falg = false
        function num(falg) {
            let shu = +prompt("请输入要查找的数")
            if (arr.indexOf(shu) != -1) {
                falg = true
            } else {
                falg = false
            }
            return falg
        }
        document.write(num(falg))

        // 查找下标
        let index = -1
        function findIndex(index) {
            let cha = +prompt("查下标")
            if(arr.indexOf(cha) != -1){
                index = arr.indexOf(cha)
                return index
            }else {
                index = -1
                return index
            }
        }
        document.write(findIndex())
    </script>
</body>

</html>